package com.demo.service;

import com.demo.common.Result;
import com.demo.entity.TestObject;
import com.demo.mapper.TestMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TestService {

    @Resource
    private TestMapper testMapper;

    public List<TestObject> selectAll() {
        List<TestObject> list = testMapper.selectAll();
        return list;
    }

    public List<TestObject> selectById(Integer id) {
        List<TestObject> list = testMapper.selectById(id);
        return list;
    }

    public PageInfo<TestObject> selectPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<TestObject> list = testMapper.selectAll();
        return PageInfo.of(list);
    }

    public void add(TestObject testObject) {
        testMapper.insert(testObject);
    }

    public void update(TestObject testObject) {
        testMapper.updateById(testObject);
    }

    public void deleteById(Integer id) {
        testMapper.deleteById(id);
    }
}
